package com.ge.modules.sys.controller;

import java.util.List;
import java.util.Map;

import com.ge.common.utils.PageUtils;
import com.ge.common.utils.Query;
import com.ge.common.utils.R;
import com.ge.modules.entity.TbRationEntity;
import com.ge.modules.sys.service.SysRationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * 抽佣比例

 * 
 * @author Luo
 * @email www.baidu.com
 * @date 2018-04-12 09:56:16
 */
@RestController
@RequestMapping("/sys/ration")
public class SysRationController {

	@Autowired
	private SysRationService sysRationService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("sys:ration:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<TbRationEntity> rationList = sysRationService.queryList(query);
		int total = sysRationService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(rationList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
//	/**
//	 * 信息
//	 */
//	@RequestMapping("/info/{id}")
//	@RequiresPermissions("sys:ration:info")
//	public R info(@PathVariable("id") Integer id){
//		TbRationEntity ration = sysRationService.queryObject(id);
//
//		return R.ok().put("ration", ration);
//	}
	
	/**
	 * 新建抽佣比列
	 */
	@RequestMapping("/save")
	@RequiresPermissions("sys:ration:save")
	public R save(@RequestBody TbRationEntity ration){
		sysRationService.save(ration);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("sys:ration:update")
	public R update(@RequestBody TbRationEntity ration){
		sysRationService.update(ration);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("sys:ration:delete")
	public R delete(@RequestBody Integer[] ids){
		sysRationService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
